/**
 * interface Definitions
 *
 * Contains constants used by multiple classes (like values of pieces)
 *
 * @author: Jonatan Pettersson
 * Created:	2006-12-14
 * Last update: 2006-12-18
 */

package engine;


public interface Constants
{
	// Constants for type of move
	public static final int NORMAL_MOVE = 0;
	public static final int SHORT_CASTLE = 1;
	public static final int LONG_CASTLE = 2;
	public static final int EN_PASSANT = 3;
	public static final int PROMOTION_QUEEN = 4;
	public static final int PROMOTION_ROOK = 5;
	public static final int PROMOTION_BISHOP = 6;
	public static final int PROMOTION_KNIGHT = 7;
	// END special moves constans

	// Side to move
	public static final int WHITE_TO_MOVE = 1;
	public static final int BLACK_TO_MOVE = -1;
	// END side to move

	// constants for pieces and piece checks
	public static final int WHITE_PAWN = 1;
	public static final int WHITE_KNIGHT = 2;
	public static final int WHITE_KING = 3;
	public static final int WHITE_BISHOP = 5;
	public static final int WHITE_ROOK = 6;
	public static final int WHITE_QUEEN = 7;
	
	public static final int BLACK_PAWN = -1;
	public static final int BLACK_KNIGHT = -2;
	public static final int BLACK_KING = -3;
	public static final int BLACK_BISHOP = -5;
	public static final int BLACK_ROOK = -6;
	public static final int BLACK_QUEEN = -7;
	
	public static final int SLIDING_CHECK = 4;
	public static final int SLIDE_DIAGONAL_CHECK = 1;
	public static final int SLIDE_LINEAR_CHECK = 2;
	
	public static final int EMPTY_SQUARE = 0;
	public static final int NO_CAPTURE = 5000;  // an impossible value
	public static final int OFF_BOARD = -1;
	// END piece constants

	// piece array locations
	
	
	// Evaluation constants
	public static final int QUEEN_VALUE = 900;
	public static final int ROOK_VALUE = 500;
	public static final int BISHOP_VALUE = 300;
	public static final int KNIGHT_VALUE = 300;
	public static final int PAWN_VALUE = 100;
	public static final int MATE_VALUE = 100000;
	public static final int DRAW_VALUE = 0;
	
	public static final int BACK_ROW_PENALTY = -25;
	public static final int CENTER_SQUARE_BONUS = 10;
	public static final int CASTLING_BONUS = 100;
	public static final int SAFE_KING_BONUS = 30;
	public static final int CASTLING_PENALTY = -50;
	
	public static final int OPENING = 1;
	public static final int MIDDLE_GAME = 2;
	public static final int END_GAME = 3;
	

	// This array is used for fast evaluation of pieces.
	//
	// Take the integer representing the piece + 7 to get the value
	//
	// E.g. Found black queen
	// -2 + 7 = 5 (looking up in the array will give -QUEEN_VALUE = black queen)
	public static final int[] PIECE_VALUE_ARRAY =
	{ -QUEEN_VALUE,		
		-ROOK_VALUE,	
		-BISHOP_VALUE,	
		0,	
		0,		
		-KNIGHT_VALUE,
		-PAWN_VALUE,	
		0,			
		PAWN_VALUE,		
		KNIGHT_VALUE,
		0,		
		0,		
		BISHOP_VALUE,		
		ROOK_VALUE,
		QUEEN_VALUE};	  	


	// END evaluation constants

	// Constants for castling availability
	public static final int CASTLE_NONE = 0;
	public static final int CASTLE_SHORT = 1;
	public static final int CASTLE_LONG = 2;
	public static final int CASTLE_BOTH = 3;
	// END Castling availability constans

	// Piece deltas
	public static int[] bishop_delta = {-15, -17, 15, 17, 0, 0, 0, 0};
	public static int[] rook_delta = {-1, -16, 1, 16, 0, 0, 0, 0};
	public static int[] queen_delta = {-15, -17, 15, 17, -1, -16, 1, 16};
	public static int[] king_delta = {-15, -17, 15, 17, -1, -16, 1, 16};
	public static int[] knight_delta = {18, 33, 31, 14, -31, -33, -18, -14};
	public static int[] pawn_delta = {16, 32, 17, 15, 0, 0, 0, 0};
	// END piece deltas

	// Attack- and delta-array and constants
	public static int ATTACK_NONE = 0; // Deltas that no piece can move
	public static int ATTACK_KQR = 1; // One square up down left and right
	public static int ATTACK_QR = 2; // More than one square up down left and right
	public static int ATTACK_KQBwP = 3; // One square diagonally up
	public static int ATTACK_KQBbP = 4; // One square diagonally down
	public static int ATTACK_QB = 5; // More than one square diagonally
	public static int ATTACK_N = 6; // Knight moves

	// Formula: attacked_square - attacking_square + 128 = pieces able to attack

	public static final int[] ATTACK_ARRAY =
	{0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,2,0,0,0,     //0-19
  	 0,0,0,5,0,0,5,0,0,0,0,0,2,0,0,0,0,0,5,0,     //20-39
	 0,0,0,5,0,0,0,0,2,0,0,0,0,5,0,0,0,0,0,0,     //40-59
	 5,0,0,0,2,0,0,0,5,0,0,0,0,0,0,0,0,5,0,0,     //60-79
	 2,0,0,5,0,0,0,0,0,0,0,0,0,0,5,6,2,6,5,0,     //80-99
	 0,0,0,0,0,0,0,0,0,0,6,4,1,4,6,0,0,0,0,0,     //100-119
	 0,2,2,2,2,2,2,1,0,1,2,2,2,2,2,2,0,0,0,0,     //120-139
	 0,0,6,3,1,3,6,0,0,0,0,0,0,0,0,0,0,0,5,6,     //140-159
	 2,6,5,0,0,0,0,0,0,0,0,0,0,5,0,0,2,0,0,5,     //160-179
	 0,0,0,0,0,0,0,0,5,0,0,0,2,0,0,0,5,0,0,0,     //180-199
	 0,0,0,5,0,0,0,0,2,0,0,0,0,5,0,0,0,0,5,0,     //200-219
	 0,0,0,0,2,0,0,0,0,0,5,0,0,5,0,0,0,0,0,0,     //220-239
	 2,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0         }; //240-256


	// Same as attack array but gives the delta needed to get to the square

	public static final int[] DELTA_ARRAY =
	{  0,   0,   0,   0,   0,   0,   0,   0,   0, -17,   0,   0,   0,   0,   0,   0, -16,   0,   0,   0,
	   0,   0,   0, -15,   0,   0, -17,   0,   0,   0,   0,   0, -16,   0,   0,   0,   0,   0, -15,   0,
	   0,   0,   0, -17,   0,   0,   0,   0, -16,   0,   0,   0,   0, -15,   0,   0,   0,   0,   0,   0,
	 -17,   0,   0,   0, -16,   0,   0,   0, -15,   0,   0,   0,   0,   0,   0,   0,   0, -17,   0,   0,
	 -16,   0,   0, -15,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, -17, -33, -16, -31, -15,   0,
	   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, -18, -17, -16, -15, -14,   0,   0,   0,   0,   0,
	   0,  -1,  -1,  -1,  -1,  -1,  -1,  -1,   0,   1,   1,   1,   1,   1,   1,   1,   0,   0,   0,   0,
	   0,   0,  14,  15,  16,  17,  18,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  15,  31,
	  16,  33,  17,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  15,   0,   0,  16,   0,   0,  17,
	   0,   0,   0,   0,   0,   0,   0,   0,  15,   0,   0,   0,  16,   0,   0,   0,  17,   0,   0,   0,
	   0,   0,   0,  15,   0,   0,   0,   0,  16,   0,   0,   0,   0,  17,   0,   0,   0,   0,  15,   0,
	   0,   0,   0,   0,  16,   0,   0,   0,   0,   0,  17,   0,   0,  15,   0,   0,   0,   0,   0,   0,
	  16,   0,   0,   0,   0,   0,   0,  17,   0,   0,   0,   0,   0,   0,   0,   0,   0};
	// END Attack- and delta-array and constants


}
